Github Actions怎么使用
想要 GitHub Actions 为我们执行自动化任务,我们需要先创建一个配置文件。该文件名任意,但必须是 yml
格式的文件,且必须放在代码仓库根目录下的.github/workflows
目录中。
比如官方提供的 仓库名/.github/workflows/hexo.yaml
示例。
# Sample workflow for building and ==deploy==ing a Hexo site to GitHub Pages
name: ==Deploy== Hexo site to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: [$default-branch]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow ==deploy==ment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent ==deploy==ment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production ==deploy==ments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
# Default to bash
defaults:
run:
shell: bash
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Install Dependencies
run: npm install
- name: Build with Hexo
run: npx hexo g
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./public
# ==Deploy==ment job
==deploy==:
environment:
name: github-pages
url: ${{ steps.==deploy==ment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: ==Deploy== to GitHub Pages
id: ==deploy==ment
uses: actions/==deploy==-pages@v2
!Actions示意图
怎么部署静态博客?